from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect,HttpResponse
import time,subprocess


def showlog(request):
    return render_to_response('log.html',locals())

def monitorlog(request):
    p = subprocess.Popen('tail -50 /cihi/app/logs/monitor.log',shell=True,stderr=subprocess.PIPE,stdout=subprocess.PIPE)
    err = p.stderr.readlines()
    data = p.stdout.readlines()
    now = time.strftime('%Y-%m-%d %H:%M:%S')
    return render_to_response('showlog.html',locals())

def maillog(request):
    p = subprocess.Popen('tail -50 /cihi/app/logs/notifymail.log',shell=True,stderr=subprocess.PIPE,stdout=subprocess.PIPE)
    err = p.stderr.readlines()
    data = p.stdout.readlines()
    now = time.strftime('%Y-%m-%d %H:%M:%S')
    return render_to_response('showlog.html',locals())
